#include<cstdio>
#include<iostream>
#include<cmath>
#include<cstring>
using namespace std;
int n,i[200200],a[200200],b[200200];
int main(){
	freopen("fruit.in","r",stdin);
	freopen("fruit.out","w",stdout);
	scanf("%d",&n);
	for(int q=1;q<=n;q++){
		scanf("%d",&i[q]);
	}
	int a1=i[1],Now=1,l=1,r=0;
	for(int q=1;q<=n;q++){
		if(a1!=i[q]){
			a1=i[q];
			a[Now]=l;
			b[Now]=r-l+1;
			Now++;
			l=q;
			r=q;
		}
		else{
			r++;
			if(q==n){
				a[Now]=l;
				b[Now]=r-l+1;
				Now++;
			}
		}
	}
	Now--;
	while(n>0){
		for(int q=1;q<=Now;q++){
			if(b[q]>0){
				printf("%d ",a[q]);
				a[q]++;
				b[q]--;
				n--;
			}
			else q++;
		}
		printf("\n");
	}
	fclose(stdin);
	fclose(stdout);
	return 0;
}
